<template>
	<view class="contents">
		<view class="detail-header">
			<view class="left" v-if="orderFrom[0]._status._type != -2">
				<view class="waitdeal">请等待商家处理</view>
				<view class="time">您的申请已经提交,还剩2天23小时59分</view>
			</view>
			<view class="left" v-if="orderFrom[0]._status._type == -2">已退款</view>
			<view class="right">
				<view class="contactcustomer">联系客服</view>
				<button open-type="contact">联系客服</button>
			</view>
		</view>
		<view class="refundinformation">
			<text>退款信息</text>
		</view>
		<view class="" style="height: 28rpx;"></view>
		<view class="" v-for="item,index in orderFrom" :key="item.id">
			<view class="refund_list" v-for="(item,index) in item.cartInfo" :key="index">
				<view class="refund_content">
					<view class="refund_img">
						<image :src="item.productInfo.image" mode=""></image >
					</view>
					<view class="refund_text">
						<view class="refund_title">
							{{item.productInfo.store_name}}
						</view>
						<view class="refund_detail">
							{{item.is_spec==0?item.productInfo.store_info:item.spec.sku}}
						</view>
					</view>
				</view>
			</view>
		</view>
		
		<view class="" style="height: 28rpx;"></view>
		<view class="refunddetails">
			<view class="refundlist" style="margin-top: 0;">
				<view class="refundtitle">退款原因</view>
				<view class="refundcontent">{{orderFrom[0].refund_reason_wap}}</view>
			</view>
			<view class="refundlist">
				<view class="refundtitle">退款金额</view>
				<view class="refundcontent">￥{{orderFrom[0].total_price}}</view>
			</view>
			<view class="refundlist">
				<view class="refundtitle">申请件款</view>
				<view class="refundcontent">{{orderFrom[0].cartInfo[0].cart_num}}</view>
			</view>
			<view class="refundlist">
				<view class="refundtitle">申请时间</view>
				<view class="refundcontent">{{orderFrom[0].refund_application_time}}</view>
			</view>
			<view class="refundlist" style="margin-bottom: 0;">
				<view class="refundtitle">退款编号</view>
				<view class="refundcontent">{{orderFrom[0].order_id}}</view>
			</view>
		</view>
		<view class="fooder" @click="cheXiaoTuiKuan" v-if="orderFrom[0]._status._type == -1">
			<view class="">撤销申请退款</view>
		</view>
	</view>
</template>

<script>
	import {refundDetail,chexiaoTuikaun} from '@/api/api.js'
	export default {
		data() {
			return {
				orderId:'',
				orderFrom:[],
				orderList:[]
			}
		},
		onLoad(options) {
			this.orderId = options.orderId
			this.refundDetail(options.orderId)
		},
		methods: {
			refundDetail(id){
				let data = `uni=${id}`;
				refundDetail(data).then(res=>{
					this.orderFrom = res.data.data.order
					this.orderList = res.data.data.order.cartInfo
				})
			},  
			// a
			cheXiaoTuiKuan(){
				let that = this;
				uni.showModal({
					title: '提示',
					content: '是否确定撤销退款申请',
					success: function (res) {
						if (res.confirm) {
							let data = `uni=${that.orderId}`
							chexiaoTuikaun(data).then(res=>{
								if(res.data.code == '200'){
									uni.showToast({
										title:'撤销申请成功',
										duration:1000
									})
									let time = setTimeout(()=>{
									uni.reLaunch({
										url:'/myIndex/myorder/myorder?index='+2
									})	
									},1000)
								}
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});	
			},
		}
	}
</script>

<style lang="scss">
	.contents {
		width: 100%;
		min-height: 100vh;
		background-color: rgb(247, 249, 252);
		.detail-header{
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 28rpx;
			.left{
				// display: flex;
				// flex-direction: column;
				.waitdeal{
					font-size: 28rpx;
					font-weight: 600;
				}
				.time{
					color: rgb(123, 123, 123);
					font-size: 20rpx;
					margin-top: 10rpx;
				}
			}
			.right{
				position: relative;
				button {
					top: 0;
					// padding: 0 !important;
					margin: 0 !important;
					position: absolute;
					font-size: 28rpx;
					opacity: 0;
				}
			}
			.contactcustomer{
			width: 162rpx;
			height: 52rpx;
			border: 2rpx solid rgb(0, 0, 0);
			border-radius: 34rpx;
			color: rgb(0, 0, 0);
			font-size: 24rpx;
			text-align: center;
			line-height: 52rpx;
		}
		}
		.refundinformation{
			font-size: 28rpx;
			background-color: #fff;
			padding: 28rpx;
		}
		.refund_list{
			
			.refund_content{
				box-sizing: border-box;
				padding: 0 28rpx;
				width: 100%;
				height: 182rpx;
				display: flex;
				.refund_img{
					width: 182rpx;
					height: 182rpx;
					flex-shrink: 0;
					image{
						border-radius: 8rpx;
						width: 100%;
						height: 100%;
					}
				}
				.refund_text{
					margin-left: 30rpx;
					width: 470rpx;
					// display: flex;
					// flex-direction: column;
					// justify-content: space-between;
					.refund_title{
						/* margin-top: 10rpx; */
						width: 100%;
						height: 40rpx;
						line-height: 40rpx;
						font-size: 26rpx;
						color: #333;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
						-o-text-overflow:ellipsis;
					}
					.refund_detail{
						margin-top: 10rpx;
						width: 470rpx;
						height: 40rpx;
						line-height: 40rpx;
						font-size: 22rpx;
						color: #999999;
						text-overflow: ellipsis;
						white-space: nowrap; 
						overflow: hidden;
					}
				}
			}
		}
		.refunddetails{
			padding: 28rpx;
			background-color: #fff;
			.refundlist {
				font-size: 26rpx;
				display: flex;
				margin: 28rpx 0;
				.refundtitle{
					width: 182rpx;
					color: #999999;
				}
				.refundcontent{
					
				}
			}
		}		
}
.fooder {
	display: flex;
	justify-content: center;
	margin-top: 40rpx;
	view {
		background-color: #1aa034;
		color: #fff;
		font-size: 26rpx;
		width: 600rpx;
		height: 70rpx;
		line-height: 70rpx;
		text-align: center;
		border-radius: 50rpx;
	}
}
</style>
